<template>
    <div>
        <div class="searchInput">
            <div class="kuang">
                <div>
                    模板名称： <el-input v-model="search_model_name" placeholder="请输入模板名称"></el-input>&emsp;&emsp13;
                </div>
                <div>
                    状态：   <el-select style="width: 90px;font-size: 12px;" v-model="searchState" placeholder="请选择">
                                    <el-option
                                    v-for="item in stateOptions"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
            </div>
        </div>
        <div class="btns">
            <el-button class="chaxun">查询</el-button>
            <el-button class="reset">重置</el-button>
        </div>
        </div>
        <div class="addBtn">
            <el-button class="newAdd" @click="$router.push('/addFeeRules')"><i class="el-icon-plus"></i>新增</el-button>
        </div>
        <!-- 数据 -->
        <el-table
            :header-cell-style="{background:'#e8efff',color:'#000000'}"
            :data="tableData"
            :loading="loading"
            style="width: 100%">
            <el-table-column
            type="selection"
            width="55">
            </el-table-column>
            <el-table-column prop="order" label="序号" width="60">
                <template v-slot="scope">
                    <div style="color:#949BBE;">
                        {{ scope.row.order }}
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="formwork" label="模板名称">
                <template v-slot="scope">
                    <div style="color:#949BBE;">
                        {{ scope.row.formwork }}
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="power_station" label="应用电站">
                <template v-slot="scope">
                    <div style="color:#949BBE;">
                        {{ scope.row.power_station }}
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="state" label="状态">
                <template v-slot="scope">
                    <div>
                        <el-switch
                            v-model="scope.row.state"
                            @change="changeState"
                            active-color="#165BFF"
                            inactive-color="#D9D9D9">
                        </el-switch>
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="created_time" label="创建时间">
                <template v-slot="scope">
                    <div style="color:#949BBE;">
                        {{ scope.row.created_time }}
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="address" label="操作">
                <template v-slot="scope">
                    <div class="scope" style="color:#949BBE;">
                        <span class="editBtn" @click="goEdit(scope.row.id)">编辑</span>
                        <span class="detailBtn" @click="goDetail(scope.row.id)">详情</span>
                        <span class="deleteBtn" @click="deleteData(scope.row.id)">删除</span>
                    </div>
                </template>
            </el-table-column>
        </el-table>
        <Pagination />
    </div>
</template>

<script>
import Pagination from '@/components/Pagination.vue'
    export default {
        components:{
            Pagination
        },
        data() {
            return {
                loading:true,
                searchState:'',
                search_model_name:'',
                stateOptions: [
                            {
                            value: null,
                            label: '请选择'
                            }, 
                            {
                            value: 1,
                            label: '启用'
                            }, 
                            {
                            value: 0,
                            label: '禁用'
                            }, 
                            ],
                tableData: [
                    {
                        order: '1',
                        formwork: '费用规则1',
                        power_station: '1',
                        state:0,
                        created_time:'2023.03.03',
                        id:1
                    },
                    {
                        order: '2',
                        formwork: '费用规则2',
                        power_station: '1',
                        state:0,
                        created_time:'2023.03.03',
                        id:1
                    },
                    {
                        order: '3',
                        formwork: '费用规则3',
                        power_station: '1',
                        state:0,
                        created_time:'2023.03.03',
                        id:1
                    },
                    {
                        order: '4',
                        formwork: '费用规则4',
                        power_station: '1',
                        state:0,
                        created_time:'2023.03.03',
                        id:1
                    },
                    {
                        order: '5',
                        formwork: '费用规则5',
                        power_station: '1',
                        state:0,
                        created_time:'2023.03.03',
                        id:1
                    },
                ]
                }
        },
        methods: {
            changeState(){
                
            },
            deleteData(){
                this.$confirm('您确定删除当前项吗', '提示', {
                    cancelButtonText: '取消',
                    confirmButtonText: '确定',
                    title:'操作提示',
                    center: true
                    }).then(() => {
                        this.$message({
                        type: 'success',
                        message: '删除成功!'
                        });
                    }).catch(() => {
                        this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                    
                });
            },
            goEdit(id){
                this.$router.push({
                    path:'/addFeeRules',
                    query:{
                        revise:"revise", // 修改
                        id
                    }
                })
            },
            goDetail(id){
                this.$router.push({
                    path:'/addFeeRules',
                    query:{
                        id,
                        detail:"inquire" // 查询
                    }
                })
            },
        }
    }
</script>

<style lang="less" scoped>
.searchInput{
    text-align: left;
    font-size: 14px;
    height: 25.97px;
    font-family: PingFang SC-Regular, PingFang SC;
    font-weight: 400;
    color: #666666 !important;
}
.el-input{
    width: 280px;
    height: 35.98px;
    font-size: 11.97px;
    color: #666666;
    background: #F0F1F6;
}
.el-input__inner{
  background-color: #F0F1F6;  
  background-color: pink !important;  
}
.el-select{
    width: 280px;
    height: 35.98px;
}
.kuang{
    float: left;
}
.btns{
    float: right;
}
.el-button{
    background: transparent;
    border: none;
}
.chaxun{
    background: #165BFF;
    color: white;
}
.reset{
    background: #F0F1F6;
    color: #666666;
}
.addBtn{
    text-align: left;
    margin-top: 31.99px;
}
.newAdd{
    background: #165BFF;
    color: white;
    width: 92px;
    height: 36px;
}
::v-deep .el-table th > .cell {
  text-align: center;
}

::v-deep .el-table .cell {
  text-align: center;
}
.editBtn{
    display: inline-block;
    margin-right: 7.98px;
    color: #09D796;
    cursor: pointer;
}
.detailBtn{
    margin-right: 7.98px;
    display: inline-block;
    color: #165BFF;
    cursor: pointer;
}
.deleteBtn{
    display: inline-block;
    color: #FA698D;
    cursor: pointer;
}
.confirmButtonClass{
    background: #165bff;
}
#dialog .el-dialog__header {
    padding: 20.02px 20.02px 0px;
    background: #165BFF;
    text-align: left;
    font-weight: bold;
}
#dialog .el-dialog__body{
    height: 188.02px;
}
.kuang>div{
    margin: 4.97px auto;
    display: inline-block;
}
.btns .el-button{
    margin: 4.97px auto;
}
.el-table{
    margin-top: 32px;
}
</style>